/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tintuna.cca.data;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Date;
import org.openide.util.Lookup;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;

/**
 *
 * @author bsmith
 */
public class Row implements Lookup.Provider {

    private final Lookup lookup;
    private final InstanceContent instanceContent;
    private final PropertyChangeSupport propertyChangeSupport;

    private Date date = null;
    private Double amount = null;
    private String TransactionType = null;
    private String Merchant = null;
    private Double Balance = null;
    private String category;

    public Row() {
        super();
        instanceContent = new InstanceContent();
        lookup = new AbstractLookup(instanceContent);
        propertyChangeSupport = new PropertyChangeSupport(this);
        init();
    }

    public Row(Date date, Double amount, String TransactionType, String Merchant, Double Balance, String category) {
        this();
        setDate(date);
        setAmount(amount);
        setTransactionType(TransactionType);
        setMerchant(Merchant);
        setBalance(Balance);
        setCategory(category);
    }

    public Row(Date date, Double amount, String TransactionType, String Merchant, Double Balance) {
        this();
        setDate(date);
        setAmount(amount);
        setTransactionType(TransactionType);
        setMerchant(Merchant);
        setBalance(Balance);
    }

    private void init() {
        // add abilities
        // this.instanceContent.add(new Reloadable() {...});
    }

    public Double getBalance() {
        return Balance;
    }

    public void setBalance(Double Balance) {
        this.Balance = Balance;
    }

    public String getMerchant() {
        return Merchant;
    }

    public void setMerchant(String Merchant) {
        this.Merchant = Merchant;
    }

    public String getTransactionType() {
        return TransactionType;
    }

    public void setTransactionType(String TransactionType) {
        this.TransactionType = TransactionType;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        String oldCategory = this.category;
        this.category = category;
        //propertyChangeSupport.firePropertyChange("category", oldCategory, category);
    }

//    public String getName() {
//        return "";
//    StringBuilder sb = new StringBuilder();
//        sb.append("Row - Date:").append(getDate());
//        sb.append(", trans type:").append(getTransactionType());
//        sb.append(", amount:").append(getAmount());
//        return sb.toString();
//    }
    @Override
    public Lookup getLookup() {
        return lookup;
    }
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }
}
